<template>
    <div class="quotation-list-page">
        <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
            <!--待报价明细-->
            <el-tab-pane :label="nowLangue.bidDetails" name="first">
                <!--查询条件-->
                <el-form :model="quotationListForm" :inline="true" style="border-bottom:1px solid #ccc;">
                    <!--法人名称-->
                    <el-form-item :label="nowLangue.legalName" class="selectMB10 label-w1 " v-if="!powerFlag" >
                        <el-input size="mini" v-if="legalPersonDropDown.length==1" disabled v-model="quotationListForm.legalPersonName" placeholder=""></el-input>
                        <el-select size="mini" clearable v-else  v-model="quotationListForm.legalPersonId" :placeholder="nowLangue.pleaseSelect" @change="changeLegalPerson">
                            <el-option v-for="(legalPerson,index) in legalPersonDropDown" :key="index" :label="legalPerson.legalPersonName" :value="legalPerson.id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <!--报价单位-->
                    <el-form-item :label="nowLangue.quotationUnit" class="selectMB10 label-w1">
                        <el-select size="mini" clearable  v-model="quotationListForm.vendorCode" :placeholder="nowLangue.pleaseSelect" v-if="!powerFlag">
                            <el-option v-for="(vendor,index) in quotationListForm.selectDropdown" :key="index" :label="vendor.partnerName" :value="vendor.partnerCode"></el-option>
                        </el-select>
                        <el-input size="mini" v-model="quotationListForm.vendorName" placeholder="" v-else disabled></el-input>
                    </el-form-item>
                    <!--询价单号-->
                    <el-form-item :label="nowLangue.inquiryNo" class="selectMB10 label-w1" >
                        <el-input size="mini" v-model="quotationListForm.requestForQuotationId" :placeholder="nowLangue.pleaseImport+nowLangue.inquiryNo"></el-input>
                    </el-form-item>
                    <!--备件编码-->
                    <el-form-item :label="nowLangue.spareCode" class="selectMB10 label-w1">
                        <el-input size="mini" v-model="quotationListForm.spareCoding" :placeholder="nowLangue.pleaseImport+nowLangue.spareCode"></el-input>
                    </el-form-item>
                    <!--备件名称-->
                    <el-form-item :label="nowLangue.spareName" class="selectMB10 label-w1">
                        <el-input size="mini" v-model="quotationListForm.spareName" :placeholder="nowLangue.pleaseImport+nowLangue.spareName"></el-input>
                    </el-form-item>
                    <!--报价状态-->
                    <el-form-item :label="nowLangue.biddingStatus" v-if="activeName=='second'" class="selectMB10 label-w1">
                        <el-select v-model="quotationListForm.biddingStatus" :placeholder="nowLangue.pleaseSelect" size="mini" clearable>
                            <el-option v-for="(statusObj,index) in statusLists" :key="index" :label="statusObj.label" :value="statusObj.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item class="selectMB10">
                        <!--查询-->
                        <el-button class="bolder outsideBtnBS selectAll" :disabled="selectDisabled" size="mini" type="danger" @click="onSubmit" v-text="nowLangue.query"></el-button>
                    </el-form-item>
                </el-form>
                <div class="block">
                    <!--报价列表-->
                    <label class="default-label" v-text="nowLangue.quotationList"></label>
                    <span class="wrapper">
                        <!--反选-->
                        <el-button type="danger" size="mini" class="bolder outsideBtnBS" @click="reverseSelection(tableData)" v-text="nowLangue.reverseSelection"></el-button>
                        <!--创建报价单-->
                        <el-button type="danger" size="mini" class="bolder outsideBtnBS" v-if="powerFlag1" @click="create" v-text="nowLangue.create"></el-button>
                    </span>
                </div>
                <!--表格-->
                <el-table ref="multipleTable" :data="tableData" border style="width: 100%; " @selection-change="handleSelectionChange">
                    <!--序-->
                    <el-table-column type="index"  header-align="center" align="center" :label="nowLangue.sequence"  width="40"></el-table-column>
                    <el-table-column type="selection"  align="center"  width="40"></el-table-column>
                    <!--询价单号-->
                    <el-table-column prop="requestForQuotationId" :label="nowLangue.inquiryNo"  header-align="center"  show-overflow-tooltip> </el-table-column>
                    <!--备件编码-->
                    <el-table-column prop="spareCoding" :label="nowLangue.spareCode"  header-align="center" show-overflow-tooltip> </el-table-column>
                    <!--备件名称-->
                    <el-table-column prop="spareName" :label="nowLangue.spareName"  header-align="center"  show-overflow-tooltip> </el-table-column>
                    <!--计量单位-->
                    <el-table-column prop="measurementUnit" :label="nowLangue.materialUnit"  header-align="center"  show-overflow-tooltip> </el-table-column>
                    <!--报价数量-->
                    <el-table-column prop="inquiryQty" :label="nowLangue.quotedQuantity"  header-align="center" show-overflow-tooltip> </el-table-column>
                    <!---->
                    <el-table-column prop="currencyCode" :label="nowLangue.quotedCurrency"  header-align="center"  show-overflow-tooltip> </el-table-column>
                    <!--含税单价金额-->
                    <el-table-column prop="includingTaxPrice" :label="nowLangue.includingTaxPrice"  header-align="center" width="100" show-overflow-tooltip> </el-table-column>
                    <!--不含税单价金额-->
                    <el-table-column prop="quotationAmount" :label="nowLangue.quotationAmount"  header-align="center" width="100" show-overflow-tooltip> </el-table-column>
                    <!--税率(%)-->
                    <el-table-column prop="taxRate" :label="nowLangue.taxRateSign"  header-align="center" show-overflow-tooltip> </el-table-column>
                    <!---->
                    <el-table-column prop="MOQ" label="MOQ"  header-align="center" width="100" show-overflow-tooltip> </el-table-column>
                    <!--供货周期（天）-->
                    <el-table-column prop="deliveryCycle" :label="nowLangue.supplyCycle"  header-align="center" width="100" show-overflow-tooltip> </el-table-column>
                    <!--报价生效日期-->
                    <el-table-column prop="startTime" :label="nowLangue.takeEffectiveDateOfQuotation"  header-align="center" width="100"  show-overflow-tooltip> </el-table-column>
                    <!--报价失效日期-->
                    <el-table-column prop="endTime" :label="nowLangue.expiryDateOfQuotation"  header-align="center" width="100"  show-overflow-tooltip> </el-table-column>
                    <!--报价日期-->
                    <el-table-column prop="createTime" :label="nowLangue.quotationDate"  header-align="center" width="100"  show-overflow-tooltip> </el-table-column>
                    <!--报价单位-->
                    <el-table-column prop="vendor" :label="nowLangue.quotationUnit"  header-align="center"  show-overflow-tooltip> </el-table-column>
                    <!--说明-->
                    <el-table-column prop="explain" :label="nowLangue.explain"  header-align="center"  show-overflow-tooltip> </el-table-column>
                </el-table>
                <!--分页-->
                <el-pagination v-if="isPaging" @size-change="handleSizeChange" @current-change="handleCurrentChange"
                               :current-page.sync="currentPage" :current-page="pageIndex"
                               :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
                               :page-count="totalPage" :total="totalNumber">
                </el-pagination>
            </el-tab-pane>
            <!--已报价明细-->
            <el-tab-pane :label="nowLangue.quotedDetails" name="second">
                <!--查询条件-->
                <el-form :model="quotationListForm2" :inline="true">
                    <!--法人名称-->
                    <el-form-item :label="nowLangue.legalName" class="selectMB10 label-w1" v-if="!powerFlag" >
                        <el-input size="mini" v-if="legalPersonDropDown.length==1" disabled v-model="quotationListForm.legalPersonName" placeholder=""></el-input>
                        <el-select size="mini" clearable v-else  v-model="quotationListForm2.legalPersonId" :placeholder="nowLangue.pleaseSelect" @change="changeLegalPerson">
                            <el-option v-for="(legalPerson,index) in legalPersonDropDown" :key="index" :label="legalPerson.legalPersonName" :value="legalPerson.id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <!--报价单位-->
                    <el-form-item :label="nowLangue.quotationUnit" class="selectMB10 label-w1">
                        <el-select size="mini" clearable  v-model="quotationListForm2.vendorCode" :placeholder="nowLangue.pleaseSelect" v-if="!powerFlag">
                            <el-option v-for="(vendor,index) in quotationListForm2.selectDropdown" :key="index" :label="vendor.partnerName" :value="vendor.partnerCode"></el-option>
                        </el-select>
                        <el-input size="mini" v-model="quotationListForm2.vendorName" placeholder="" v-else disabled></el-input>
                    </el-form-item>
                    <!--询价单号-->
                    <el-form-item :label="nowLangue.inquiryNo" class="selectMB10 label-w1">
                        <el-input size="mini" v-model="quotationListForm2.requestForQuotationId" :placeholder="nowLangue.pleaseImport+nowLangue.inquiryNo"></el-input>
                    </el-form-item>
                    <!--报价单号-->
                    <el-form-item label="报价单号" class="selectMB10 label-w1">
                        <el-input size="mini" v-model="quotationListForm2.quotationNumber" :placeholder="nowLangue.pleaseImport+nowLangue.quotationNumber"></el-input>
                    </el-form-item>
                    <!--备件编码-->
                    <el-form-item :label="nowLangue.spareCode" class="selectMB10 label-w1">
                        <el-input size="mini" v-model="quotationListForm2.spareCoding" :placeholder="nowLangue.pleaseImport+nowLangue.spareCode"></el-input>
                    </el-form-item>
                    <!--备件名称-->
                    <el-form-item :label="nowLangue.spareName" class="selectMB10 label-w1">
                        <el-input size="mini" v-model="quotationListForm2.spareName" :placeholder="nowLangue.pleaseImport+nowLangue.spareName"></el-input>
                    </el-form-item>
                    <!--报价状态-->
                    <el-form-item :label="nowLangue.biddingStatus" v-if="activeName=='second'" class="selectMB10 label-w1">
                        <el-select v-model="quotationListForm2.biddingStatus" :placeholder="nowLangue.pleaseSelect" size="mini" clearable>
                            <el-option v-for="(statusObj,index) in statusLists" :key="index" :label="statusObj.label" :value="statusObj.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <!--报价日期-->
                    <el-form-item :label="nowLangue.quotationDate" class="selectMB10 label-w1">
                        <el-date-picker type="date" size="mini" :editable="false" v-model="quotationListForm2.createStartTime" :placeholder="nowLangue.pleaseSelect" @change="selectedCreateStartTime"></el-date-picker>
                        &nbsp;{{nowLangue.to}}&nbsp;
                        <el-date-picker type="date" size="mini" :editable="false" v-model="quotationListForm2.createEndTime" :placeholder="nowLangue.pleaseSelect" @change="selectedCreateEndTime"></el-date-picker>
                    </el-form-item>
                    <!--报价有效日期-->
                    <el-form-item :label="nowLangue.effectiveDateOfQuotation"class="selectMB10 label-w2">
                        <div class="block">
                            <el-date-picker type="date" size="mini" :editable="false" v-model="quotationListForm2.startTime" :placeholder="nowLangue.pleaseSelect" @change="selectedStartTime"></el-date-picker>
                            &nbsp;{{nowLangue.to}}&nbsp;
                            <el-date-picker type="date" size="mini" :editable="false" v-model="quotationListForm2.endTime" :placeholder="nowLangue.pleaseSelect" @change="selectedEndTime"></el-date-picker>
                        </div>
                    </el-form-item>
                    <el-form-item class="selectMB10">
                        <!--查询-->
                        <el-button class="bolder outsideBtnBS selectAll" :disabled="selectDisabled" size="mini" type="danger" @click="onSubmit" v-text="nowLangue.query"></el-button>
                    </el-form-item>
                </el-form>
                <hr style="margin-top: 0;margin-bottom: 0px;">
                <!--报价列表-->
                <label class="default-label" v-text="nowLangue.quotationList"></label>
                <!--表格-->
                <el-table :data="tableData2" border style="width: 100%; ">
                    <!--序-->
                    <el-table-column type="index"  header-align="center" align="center" :label="nowLangue.sequence"  width="40"></el-table-column>
                    <el-table-column type="selection"  align="center"  width="40"></el-table-column>
                    <!--询价单号-->
                    <el-table-column prop="requestForQuotationId" :label="nowLangue.inquiryNo"  header-align="center"  show-overflow-tooltip> </el-table-column>
                    <!--备件编码-->
                    <el-table-column prop="spareCoding" :label="nowLangue.spareCode"  header-align="center"  show-overflow-tooltip> </el-table-column>
                    <!--备件名称-->
                    <el-table-column prop="spareName" :label="nowLangue.spareName"  header-align="center"  show-overflow-tooltip> </el-table-column>
                    <!--计量单位-->
                    <el-table-column prop="measurementUnit" :label="nowLangue.materialUnit"  header-align="center"  show-overflow-tooltip> </el-table-column>
                    <!--报价数量-->
                    <el-table-column prop="quotedQuantity" :label="nowLangue.quotedQuantity"  header-align="center" show-overflow-tooltip> </el-table-column>
                    <!--报价币别-->
                    <el-table-column prop="currencyCode" :label="nowLangue.quotedCurrency"  header-align="center"  show-overflow-tooltip> </el-table-column>
                    <!--含税单价金额-->
                    <el-table-column prop="includingTaxPrice" :label="nowLangue.includingTaxPrice"  header-align="center" width="100" show-overflow-tooltip> </el-table-column>
                    <!--不含税单价金额-->
                    <el-table-column prop="quotationAmount" :label="nowLangue.quotationAmount"  header-align="center" width="100" show-overflow-tooltip> </el-table-column>
                    <!--税率(%)-->
                    <el-table-column prop="taxRate" :label="nowLangue.taxRateSign"  header-align="center" show-overflow-tooltip> </el-table-column>
                    <el-table-column prop="moq" label="MOQ"  header-align="center" width="100" show-overflow-tooltip> </el-table-column>
                    <!--供货周期(天)-->
                    <el-table-column prop="deliveryCycle" :label="nowLangue.supplyCycle"  header-align="center" width="100" show-overflow-tooltip> </el-table-column>
                    <!--报价生效日期-->
                    <el-table-column prop="startTime" :label="nowLangue.takeEffectiveDateOfQuotation"  header-align="center" width="100"  show-overflow-tooltip> </el-table-column>
                    <!--报价失效日期-->
                    <el-table-column prop="endTime" :label="nowLangue.expiryDateOfQuotation"  header-align="center" width="100"  show-overflow-tooltip> </el-table-column>
                    <!--报价日期-->
                    <el-table-column prop="createTime" :label="nowLangue.quotationDate"  header-align="center" width="100"  show-overflow-tooltip> </el-table-column>
                    <!--报价单位-->
                    <el-table-column prop="vendor" :label="nowLangue.quotationUnit"  header-align="center"  show-overflow-tooltip> </el-table-column>
                    <!--说明-->
                    <el-table-column prop="quotationExplain" :label="nowLangue.explain"  header-align="center"  show-overflow-tooltip> </el-table-column>
                </el-table>
                <!--分页-->
                <el-pagination v-if="isPaging2" @size-change="handleSizeChange2" @current-change="handleCurrentChange2"
                               :current-page.sync="currentPage2" :current-page="pageIndex2"
                               :page-size="pageSize2" layout="total, sizes, prev, pager, next, jumper"
                               :page-count="totalPage2" :total="totalNumber2">
                </el-pagination>
            </el-tab-pane>
        </el-tabs>

    </div>
</template>
<script>
    export default {
        data(){
            return{
                nowLangue:{},
                //待明细
                quotationListForm:{
                    legalPersonId:'',
                    legalPersonName:'',
                    vendorCode:'',
                    vendorName:'',
                    requestForQuotationId:'',
                    quotationNumber:'',
                    spareCoding:'',
                    spareName:'',
                    biddingStatus:'',
                    createStartTime:'',
                    createEndTime:'',
                    startTime:'',
                    endTime:'',
                    selectDropdown:[]
                },
                legalPersonId: '',   //法人ID 查询供应商
                //已明细
                quotationListForm2:{
                    legalPersonId:'',
                    legalPersonName:'',
                    vendorCode:'',
                    vendorName:'',
                    requestForQuotationId:'',
                    quotationNumber:'',
                    spareCoding:'',
                    spareName:'',
                    biddingStatus:'',
                    createStartTime:'',
                    createEndTime:'',
                    startTime:'',
                    endTime:'',
                    selectDropdown:[]
                },
                legalPersonDropDown:[], //法人名称
                supplierNameDropDown:[], //供应商名称
                selectDropdown:[],
                statusLists:[],   //报价状态下拉列表中的值
                loading:false,
                activeName:'first',
                tableData:[],
                tableData2:[],

                isPaging:false,    //是否显示分页
                pageIndex:1,    //当前页（必传）
                pageSize :10,   //每页多少条
                currentPage:3,    //当前显示3页
                totalNumber: 20,     //总条数
                totalPage:2,    //总页数

                isPaging2:false,    //是否显示分页
                pageIndex2:1,    //当前页（必传）
                pageSize2 :10,   //每页多少条
                currentPage2:3,    //当前显示3页
                totalNumber2: 20,     //总条数
                totalPage2:2,    //总页数

                spareCodings:[],      // 选中报价明细备件编码 spareCoding vendorCode
                vendorCode:"",    // 选中报价明细的供应商编码
                //权限
                powerFlag:false,   //不是业务合作人员
                powerFlag1:false,//报价列表创建、保存、提交及导入权限
                //查询禁用
                selectDisabled:false
            }
        },
        created:function(){
            var _this=this;
            _this.languageType=="zh"?_this.nowLangue=_this.language.zh:_this.nowLangue=_this.language.en;
        },
        computed:{
            identity(){
                return this.$store.state.identity;
            },
            powerData(){   //登录人员的权限
                return this.$store.state.powerData;
            },
            languageType(){
                return this.$store.state.languageType;
            }
        },
        watch:{
            languageType(){
                var _this=this;
                _this.languageType=="zh"?_this.nowLangue=_this.language.zh:_this.nowLangue=_this.language.en;
            },
            identity(){
                var _this=this;
                if(_this.identity == 1){  //是本部人员
                    _this.legalPersonDropDownValue();
                }
                if(_this.identity == 2){
                    _this.powerFlag = true;   //是业务合作人员
                    _this.getVendorCode();  //获取当前登录用户对应的供应商
                }
            },
            powerData(){   //登录人员的权限
                var _this=this;
                for(var i=0;i<_this.powerData.length;i++){
                    if(_this.powerData[i]=="ROLE_security_quotationList_operation"){
                        //报价列表创建、保存、提交及导入权限
                        _this.powerFlag1=true;
                    }
                }
            }
        },
        mounted:function(){
            var _this=this;
            _this.$store.commit('currentActive', 'QuotationList');
            // //ajax前后查询按钮禁用
            // $(".selectAll").ajaxStart(function(){
            //     _this.selectDisabled=true;
            // });
            // $(".selectAll").ajaxStop(function(){
            //     _this.selectDisabled=false;
            // });
            if(_this.identity == 1){  //是本部人员
                _this.legalPersonDropDownValue();
            }
            if(_this.identity == 2){
                _this.powerFlag = true;   //是业务合作人员
                _this.getVendorCode();  //获取当前登录用户对应的供应商
            }
            // 当前登录人员的权限
            for(var i=0;i<_this.powerData.length;i++){
//                if(_this.powerData[i]=="ROLE_security_quotationList_operation"){
                    //报价列表创建、保存、提交及导入权限
                    _this.powerFlag1=true;
//                }
            }
            _this.statusDownValue();
            _this.onSubmit();
        },
        methods:{
            // 获取当前登录用户对应的供应商
            getVendorCode(){     //报价单位
                var _this = this;
                $.ajax({
                    type:'GET',
                    url:_this.procurement_service+"quotation/findByVendorName",
                    cache:false,
                    success:function(data){
                        if(data.success){
                            _this.quotationListForm.vendorCode = data.data[0].partnerCode;
                            _this.quotationListForm.vendorName = data.data[0].partnerName;
                            _this.quotationListForm2.vendorCode = data.data[0].partnerCode;
                            _this.quotationListForm2.vendorName = data.data[0].partnerName;
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            //报价日期
            selectedCreateStartTime(val){
                var _this=this;
                _this.quotationListForm2.createStartTime = val;
                if(_this.quotationListForm2.createEndTime && val > _this.quotationListForm2.createEndTime){
                    var err=_this.languageType=="zh"?'报价开始日期不能大于报价结束日期':'The quotation start date shall not be greater than the end date of quotation';
                    _this.common.errorTip(err);
                    _this.quotationListForm2.createStartTime = "";
                };
            },
            selectedCreateEndTime(val){
                var _this=this;
                _this.quotationListForm2.createEndTime = val;
                if(_this.quotationListForm2.createStartTime && val < _this.quotationListForm2.createStartTime){
                     var err=_this.languageType=="zh"?'报价结束日期不能小于报价开始日期':'The closing date shall not be less than the starting date of the quotation';
                    _this.common.errorTip(err);
                    _this.quotationListForm2.createEndTime = "";
                };
            },
            //报价开始日期
            selectedStartTime(val){
                var _this=this;
                _this.quotationListForm2.startTime = val;
                if(_this.quotationListForm2.endTime && val > _this.quotationListForm2.endTime){
                    var err=_this.languageType=="zh"?'报价开始日期不能大于报价结束日期':'The quotation start date shall not be greater than the end date of quotation';
                    _this.common.errorTip(err);
                    _this.quotationListForm2.startTime = "";
                };
            },
            // 报价结束日期
            selectedEndTime(val){
                var _this=this;
                _this.quotationListForm2.endTime = val;
                if(_this.quotationListForm2.startTime && val < _this.quotationListForm2.startTime){
                    var err=_this.languageType=="zh"?'报价结束日期不能小于报价开始日期':'The closing date shall not be less than the starting date of the quotation';
                    _this.common.errorTip(err);
                    _this.quotationListForm2.endTime = "";
                };
            },
            legalPersonDropDownValue(){  //法人名称下拉列表值
                var _this = this;
                $.ajax({
                    type:'GET',
                    url:_this.procurement_service+"legalPerson/ofCurrentUser",
                    cache:false,
                    success:function(data){
                        if(data.success){
                            _this.legalPersonDropDown = data.data;
                            if(_this.legalPersonDropDown.length == 1){
                                if(_this.activeName=='first'){
                                    _this.quotationListForm.legalPersonId = _this.legalPersonDropDown[0].id;
                                    _this.quotationListForm.legalPersonName = _this.legalPersonDropDown[0].legalPersonName;
                                }else{
                                    _this.quotationListForm2.legalPersonId = _this.legalPersonDropDown[0].id;
                                    _this.quotationListForm2.legalPersonName = _this.legalPersonDropDown[0].legalPersonName;
                                }
                                _this.dropdownValue();
                            }
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            // 选择法人名称  
            changeLegalPerson(){
                var _this = this;
                
                for(var i=0;i<_this.legalPersonDropDown.length;i++){
                    if(_this.activeName=='first'){
                        if(_this.quotationListForm.legalPersonName==_this.legalPersonDropDown[i].id){
                            _this.quotationListForm.legalPersonId=_this.legalPersonDropDown[i].id;
                        }
                    }else{
                        if(_this.quotationListForm2.legalPersonName==_this.legalPersonDropDown[i].id){
                            _this.quotationListForm2.legalPersonId=_this.legalPersonDropDown[i].id;
                        }
                    }
                }
                
                _this.dropdownValue();
            },
            dropdownValue(){  //供应商下拉列表值
                var _this=this;
                if(_this.activeName=='first'){
                    _this.legalPersonId=_this.quotationListForm.legalPersonId;
                }else{
                    _this.legalPersonId=_this.quotationListForm2.legalPersonId;
                }
                $.ajax({
                    type:'GET',
                    url:_this.metadata_service+"partner/queryByLegalPerson?legalPersonId="+_this.legalPersonId,
                    cache:false,
                    success:function(data){
                        if(data.success){
                            _this.quotationListForm.selectDropdown=data.data;
                            _this.quotationListForm2.selectDropdown=data.data;
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            //报价状态下拉框初始化
            statusDownValue(){
                var _this=this;
                var tmp = ["biddingStatus"];
                $.ajax({
                    type:'POST',
                    url:_this.procurement_service+'procurement/getPullDownList',
                    cache:false,
                    data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType: "application/json;charset=utf-8",
                    success:function(data){
                        if(data.success){
                            _this.statusLists = data.data.biddingStatus;    //报价状态
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            // 查询
            onSubmit(){
                var _this=this;
                _this.loading=true;
                //待报价
                if(_this.activeName=='first'){
                    var tmp={
                        legalPersonId: _this.quotationListForm.legalPersonId,
                        vendorCode: _this.quotationListForm.vendorCode,
                        requestForQuotationId: _this.quotationListForm.requestForQuotationId,
                        spareCoding: _this.quotationListForm.spareCoding,
                        spareName: _this.quotationListForm.spareName,
                        biddingStatus: _this.quotationListForm.biddingStatus,
                        pageIndex: _this.pageIndex,
                        pageSize: _this.pageSize
                    };
                    _this.selectDisabled=true;
                    $.ajax({
                        type: 'POST',
                        url: _this.procurement_service+"quotationList/searchPre",
                        cache: false,
                        data:JSON.stringify(tmp),
                        dataType:'JSON',
                        contentType: "application/json;charset=utf-8",
                        success: function (data) {
                            if (data.success) {
                                _this.loading=false;
                                var arr=data.data.dataList;
                                //单价保留八位
                                for(var i=0;i<arr.length;i++){
                                    if(arr[i].quotationAmount){
                                        arr[i].quotationAmount=arr[i].quotationAmount.toFixed(8);
                                    }
                                }
                                _this.tableData=arr;
                                _this.isPaging=true;
                                _this.totalPage=data.data.totalPage;
                                _this.totalNumber=data.data.totalNumber;
                            }else{
                                 _this.common.errorTip(data.errorMessage);
                            }
                            _this.selectDisabled=false;   
                        }
                    });
                }else{
                    //已报价
                    var tmp={
                        legalPersonId: _this.quotationListForm2.legalPersonId,
                        vendorCode: _this.quotationListForm2.vendorCode,
                        requestForQuotationId: _this.quotationListForm2.requestForQuotationId,
                        quotationNumber: _this.quotationListForm2.quotationNumber,
                        spareCoding: _this.quotationListForm2.spareCoding,
                        spareName: _this.quotationListForm2.spareName,
                        biddingStatus: _this.quotationListForm2.biddingStatus,
                        createStartTime: _this.quotationListForm2.createStartTime,
                        createEndTime: _this.quotationListForm2.createEndTime,
                        startTime: _this.quotationListForm2.startTime,
                        endTime: _this.quotationListForm2.endTime,
                        pageIndex: _this.pageIndex2,
                        pageSize: _this.pageSize2,
                    };
                    _this.selectDisabled=true;
                    $.ajax({
                        type: 'POST',
                        url: _this.procurement_service+"quotationList/search",
                        cache: false,
                        data:JSON.stringify(tmp),
                        dataType:'JSON',
                        contentType: "application/json;charset=utf-8",
                        success: function (data) {
                            if (data.success) {
                                _this.loading=false;
                                var arr=data.data.dataList;
                                //单价保留八位
                                for(var i=0;i<arr.length;i++){
                                    if(arr[i].quotationAmount){
                                        arr[i].quotationAmount=arr[i].quotationAmount.toFixed(8);
                                    }
                                }
                                _this.tableData2=arr;
                                _this.isPaging2=true;
                                _this.totalPage2=data.data.totalPage;
                                _this.totalNumber2=data.data.totalNumber;
                            }else{
                                _this.common.errorTip(data.errorMessage);
                            }
                            _this.selectDisabled=false;   
                        }
                    });
                }
            },

            handleClick(tab,event){
                var _this=this;
                _this.onSubmit();
            },
            // selection-change	当选择项发生变化时会触发该事件
            handleSelectionChange(val){
                var _this=this;
                _this.spareCodings=[];
                _this.vendorCode="";
                if(val.length==1){
                    _this.spareCodings.push(val[0].spareCoding);
                    _this.vendorCode=val[0].vendorCode;
                    _this.requestForQuotationId=val[0].requestForQuotationId;
                }else if(val.length > 1){
                    for(var i=1;i<val.length;i++){
                        if(val[i].vendorCode != val[i-1].vendorCode){
                            var err=_this.languageType=="zh"?'不属于同一个供应商！':'Does not belong to the same supplier!';
                            _this.common.errorTip(err);
                            _this.$refs.multipleTable.toggleRowSelection(val[i]);
                        }
                        if(val[i].requestForQuotationId != val[i-1].requestForQuotationId){
                            var err1=_this.languageType=="zh"?'不属于同一个询价单！':'Do not belong to the same inquiry sheet!';
                            _this.common.errorTip(err1);
                            _this.$refs.multipleTable.toggleRowSelection(val[i]);
                        }
                    }
                    for(var i=0;i<val.length;i++){
                        _this.spareCodings.push(val[i].spareCoding);
                    }
                    _this.vendorCode=val[0].vendorCode;
                    _this.requestForQuotationId=val[0].requestForQuotationId;
                }
//                 console.log(_this.spareCodings,_this.vendorCode);
            },
            create(){
                var _this=this;
                //if(_this.spareCodings.length>0){  y
                    _this.$router.push({path:"/CreateQuotation",query:{vendorCode:_this.vendorCode,requestForQuotationId:_this.requestForQuotationId,spareCodes:_this.spareCodings}});
                //}else{
                  //  _this.common.errorTip("请勾选待报价明细！");
                //}
            },
            // 反选
            reverseSelection(rows){
                var _this=this; 
                if (rows) {
                    rows.forEach(row => {
                        _this.$refs.multipleTable.toggleRowSelection(row);
                    });
                } else {
                    _this.$refs.multipleTable.clearSelection();
                }
            },
            //   待报价分页
            handleSizeChange(val) {          //每页条数
                var _this=this;
                _this.pageSize=val;
                _this.onSubmit();
            },
            handleCurrentChange(val) {       // 当前页
                var _this=this;
                _this.pageIndex=val;
                _this.onSubmit();
            },
            //  已报价 分页
            handleSizeChange2(val) {          //每页条数
                var _this=this;
                _this.pageSize2=val;
                _this.onSubmit();
            },
            handleCurrentChange2(val) {       // 当前页
                var _this=this;
                _this.pageIndex2=val;
                _this.onSubmit();
            },
            // // ===================================
            // successTip(p) {     //成功时的提示信息
            //     this.$notify({
            //         title: this.nowLangue.success,
            //         message: p,
            //         type: 'success'
            //     });
            // },
            // errorTip(p) {     //错误提示
            //     this.$notify.error({
            //         title: this.nowLangue.error,
            //         message: p
            //     });
            // }
        }
    }
</script>